<template>
    <div class="divLogin">
        <el-card class="box-card">
            <div slot="header" class="clearfix">
                <span>中科视频管理平台</span>
            </div>
            <el-form ref="form" :model="info" label-width="80px">
                <el-form-item label="用户名">
                    <el-input v-model="info.uid"></el-input>
                </el-form-item>
                <el-form-item label="密码">
                    <el-input v-model="info.pwd" type="password"></el-input>
                </el-form-item>
                <div>
                    <el-button class="btn-block" type="primary" @click="onSubmit">登录系统</el-button>
                </div>
            </el-form>
        </el-card>

    </div>
</template>

<script>
    export default {
        data(){
            return{
                title:"中科视频监控平台" ,
                info:{
                    uid:"admin" ,
                    pwd:"123456"
                }
            }
        },
        methods :{
            onSubmit(){
                var me = this;
                try{
                    var ps={
                        code:'admin' ,
                        pwd:'123'
                    }
                    me.$query('login/checklogin' , ps ).then(res=>{
                        if( res && res.length>0){
                            res[0].loginTm = ( new Date()).getTime();
                            window.sessionStorage.setItem('loginInfo' , JSON.stringify(res[0]));
                            me.$emit('onLogin' , 1>0);
                        }
                        else{
                            alert('用户名或密码错误！')
                        }
                    })
                }
                catch(er){
                    console.log(er);
                }
            }
        }
    }
</script>

<style lang="less" scoped>
    html.body{
        background-color: #d5e5f5;
    }

    .divLogin{
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -70%);
        background-color: #fafafa;
        box-shadow: 1,1,1 #999;
        width: 400px; 
    }
</style>